# kLibC Makefile

C_SRC = string.c debug.c
C_OBJ = string.o debug.o

S_SRC = 
S_OBJ = 

OBJS = $(S_OBJ) $(C_OBJ)

INCLUDES = -I./include

CC = gcc
CFLAGS = -fno-builtin -fno-pic -Wall -Wstrict-prototypes -nostdinc -nostartfiles -nodefaultlibs -m32 $(INCLUDES)

CPP = cpp
CPPFLAGS = -nostdinc $(INCLUDES)

AS = as
ASFLAGS = --32 $(INCLUDES)

LD = ld
LDFLAGS = -melf_i386 -T linker.ld

AR = ar
ARFLAGS = 

klibc.a:	$(OBJS)
	$(AR) $(ARFLAGS) rsc klibc.a $(OBJS)

.SUFFIXES:	.s .o .c .S

.S.s:
	$(CPP) $(CPPFLAGS) -o $*.s $*.S
	
.S.o:
	$(CPP) $(CPPFLAGS) -o $*.s $*.S
	$(AS) $(ASFLAGS) -o $*.o $*.s
	
.s.o:	
	$(AS) $(ASFLAGS) -o $*.o $*.s

.c.s:
	$(CC) $(CFLAGS) -S $*.c
	
.c.o:
	$(CC) $(CFLAGS) -o $*.o -c $*.c
	
clean:	
	rm *.o *.a

